/**
 * 
 */
package org.vsg.common.web.servlet.view;

import org.springframework.web.servlet.ModelAndView;

/**
 * @author Bill vison
 *
 */
public class SimpleUnifyView implements SaasUnifyView {
	
	private String relativePath;
	
	public SimpleUnifyView(String path) {
		relativePath = path;
	}
	

	/* (non-Javadoc)
	 * @see org.vsg.common.web.servlet.view.SaasUnifyView#getPrefixContext(java.lang.String)
	 */
	@Override
	public ModelAndView getModelAndView(String viewPattern) {
		// TODO Auto-generated method stub
		StringBuilder sb = new StringBuilder();
		if (!relativePath.startsWith("/")) {
			sb.append("/");
		}
		sb.append(relativePath);
		if (!viewPattern.startsWith("/")) {
			sb.append("/");
		}
		sb.append(viewPattern);
		
		ModelAndView modAndView = new ModelAndView();
		modAndView.setViewName( sb.toString());
		
		return modAndView;		
	}

}
